package cn.icanci.loopstack.bic.common.utils;

import org.apache.commons.lang3.RandomUtils;

import cn.hutool.core.lang.Snowflake;

/**
 * @author icanci
 * @since 1.0 Created in 2023/08/21 13:50
 */
public class IdHolder {
    /** 雪花序列号生成算法 */
    private static final Snowflake SNOW_FLAKE     = new Snowflake(RandomUtils.nextInt(1, 9), RandomUtils.nextInt(1, 9));

    private static final String    DEFAULT_PREFIX = "BIC";

    public static String generateBySnowFlake(String prefix) {
        return prefix + SNOW_FLAKE.nextId();
    }

    /**
     * 通过雪花算法生成唯一id，默认 BIC
     *
     * @return id
     */
    public static String generateNoBySnowFlakeDefaultPrefix() {
        return generateBySnowFlake(DEFAULT_PREFIX);
    }

}
